package com.zhp.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.math.BigDecimal;

/**
 * @author zhanghp
 * @since 2024/5/31 17:05
 */
@Getter
@AllArgsConstructor
public enum InitTypeEnums {

    NUMBER(Number.class, 0),
    BIGDECIMAL(BigDecimal.class, new BigDecimal("0.00")),
    STRING(String.class, ""),
    BOOLEAN(Boolean.class, Boolean.FALSE),
    OTHERS(Object.class, null),
    ;

    private final Class<?> cls;

    private final Object initData;

    public static Object getInit(Class<?> cls){
        if (cls == null) {
            throw new IllegalArgumentException("class 为空");
        }
        for (InitTypeEnums it : InitTypeEnums.values()) {
            if (it.getCls().equals(cls)) {
                return it.getInitData();
            }
        }
        return null;
    }
}
